|
|
|
|
|
|
|
Figure 4.3.
Adding a Restore button to the form. |
|
|
|
|
|
|
|
|
Now, add a button that invokes the UpdateRecord method. The UpdateRecord method tells Visual Basic to save the values of the bound input controls (the textbox in this project) to the Dynaset. Refer to Figure 4.4 for sizing and positioning the button. |
|
|
|
|
|
|
|
|
Figure 4.4.
Adding the Update button to the form. |
|
|
|
|
|
|
|
|
Using the UpdateRecord method updates the Dynaset without moving the record pointer. Now, add a command button to the form, set its Name property to cmdUpdate and its Caption property to &Update, and then place the following code line behind the button in the cmdUpdate_Click event: |
|
|
|
|
|
|
|
|
Private Sub cmdUpdate_Click()
data1.UpdateRecord 'write controls to dynaset
End Sub |
|
|
|
|
| |
|
|
|
|
It is important to remember the difference between the UpdateControls method and the UpdateRecord method. The UpdateControls method reads from the data object and writes to the form controls. It updates the controls. The UpdateRecord method reads from the form controls and writes to the data object. It updates the record. |
|
|
|
|
|
|
|